// src/pages/faq-management/components/FaqCategoryForm.tsx
import {ModalForm, ProFormDigit, ProFormRadio, ProFormText} from '@ant-design/pro-components';
import {ReactNode} from 'react';

interface FaqCategoryFormProps {
  trigger: ReactNode;
  onFinish: (values: API.IFaqCategory) => Promise<boolean>;
  initialValues?: API.IFaqCategory;
  formType: 'create' | 'edit';
}

const FaqCategoryForm = ({
                           trigger,
                           onFinish,
                           initialValues,
                           formType
                         }: FaqCategoryFormProps) => {
  return (
    <ModalForm
      title={formType === 'create' ? '新建问题分类' : '编辑问题分类'}
      width="500px"
      trigger={trigger as any}
      autoFocusFirstInput
      onFinish={onFinish}
      initialValues={initialValues || {status: "0", sortOrder: 0}}
    >
      <ProFormText
        name="name"
        label="分类名称"
        placeholder="请输入分类名称"
        rules={[{required: true, message: '请输入分类名称'}]}
      />
      <ProFormDigit
        name="sortOrder"
        label="排序权重"
        placeholder="请输入排序权重"
        min={0}
        fieldProps={{precision: 0}}
      />
      <ProFormRadio.Group
        name="status"
        label="状态"
        options={[
          {label: '启用', value: "0"},
          {label: '禁用', value: "1"},
        ]}
        rules={[{required: true, message: '请选择状态'}]}
      />
    </ModalForm>
  );
};

export default FaqCategoryForm;
